package com.jiankang.util;
import java.util.regex.Pattern;
public class Guolv {
	public String Html(String inputString) {      
		String htmlStr = inputString; // 含html标签的字符串      
		String textStr = "";     
		java.util.regex.Pattern p_html;      
		java.util.regex.Matcher m_html;       
		java.util.regex.Pattern p_html1;      
		java.util.regex.Matcher m_html1;      
		try {      
			String regexstrs = "<(?!/p).*?>";   //去除所有标签，只剩p,img
			p_html1 = Pattern.compile("&nbsp;|&rdquo;|&ldquo;| ", Pattern.CASE_INSENSITIVE);
			m_html1 = p_html1.matcher(htmlStr);
			htmlStr = m_html1.replaceAll(""); //去除所有空格之类的标签
			p_html = Pattern.compile(regexstrs, Pattern.CASE_INSENSITIVE);      
			m_html = p_html.matcher(htmlStr);      
			htmlStr = m_html.replaceAll("");  //去除所有标签，只剩p
			textStr = htmlStr.trim().replace("</p>","\r\n");//将所有的反斜杠p标签替换成\n
		} catch (Exception e) {    
			e.printStackTrace(); 
		}      
		return textStr;// 返回文本字符串      
	}
} 